package cn.liyicun.cp.cpweb.mapper;

import cn.liyicun.cp.cpweb.entity.MoneyLog;
import cn.liyicun.cp.cpweb.entity.MoneyLogExample;
import java.io.Serializable;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface MoneyLogMapper extends Serializable {
    @SelectProvider(type=MoneyLogSqlProvider.class, method="countByExample")
    long countByExample(MoneyLogExample example);

    @DeleteProvider(type=MoneyLogSqlProvider.class, method="deleteByExample")
    int deleteByExample(MoneyLogExample example);

    @Delete({
        "delete from money_log",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into money_log (uid, type, ",
        "type_id, create_time, ",
        "before_money, change_money, ",
        "after_money, locking, ",
        "remark)",
        "values (#{uid,jdbcType=BIGINT}, #{type,jdbcType=VARCHAR}, ",
        "#{typeId,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{beforeMoney,jdbcType=DECIMAL}, #{changeMoney,jdbcType=DECIMAL}, ",
        "#{afterMoney,jdbcType=DECIMAL}, #{locking,jdbcType=VARCHAR}, ",
        "#{remark,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(MoneyLog record);

    @InsertProvider(type=MoneyLogSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(MoneyLog record);

    @SelectProvider(type=MoneyLogSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="uid", property="uid", jdbcType=JdbcType.BIGINT),
        @Result(column="type", property="type", jdbcType=JdbcType.VARCHAR),
        @Result(column="type_id", property="typeId", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="before_money", property="beforeMoney", jdbcType=JdbcType.DECIMAL),
        @Result(column="change_money", property="changeMoney", jdbcType=JdbcType.DECIMAL),
        @Result(column="after_money", property="afterMoney", jdbcType=JdbcType.DECIMAL),
        @Result(column="locking", property="locking", jdbcType=JdbcType.VARCHAR),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR)
    })
    List<MoneyLog> selectByExampleWithRowbounds(MoneyLogExample example, RowBounds rowBounds);

    @SelectProvider(type=MoneyLogSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="uid", property="uid", jdbcType=JdbcType.BIGINT),
        @Result(column="type", property="type", jdbcType=JdbcType.VARCHAR),
        @Result(column="type_id", property="typeId", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="before_money", property="beforeMoney", jdbcType=JdbcType.DECIMAL),
        @Result(column="change_money", property="changeMoney", jdbcType=JdbcType.DECIMAL),
        @Result(column="after_money", property="afterMoney", jdbcType=JdbcType.DECIMAL),
        @Result(column="locking", property="locking", jdbcType=JdbcType.VARCHAR),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR)
    })
    List<MoneyLog> selectByExample(MoneyLogExample example);

    @Select({
        "select",
        "id, uid, type, type_id, create_time, before_money, change_money, after_money, ",
        "locking, remark",
        "from money_log",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="uid", property="uid", jdbcType=JdbcType.BIGINT),
        @Result(column="type", property="type", jdbcType=JdbcType.VARCHAR),
        @Result(column="type_id", property="typeId", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="before_money", property="beforeMoney", jdbcType=JdbcType.DECIMAL),
        @Result(column="change_money", property="changeMoney", jdbcType=JdbcType.DECIMAL),
        @Result(column="after_money", property="afterMoney", jdbcType=JdbcType.DECIMAL),
        @Result(column="locking", property="locking", jdbcType=JdbcType.VARCHAR),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR)
    })
    MoneyLog selectByPrimaryKey(Long id);

    @UpdateProvider(type=MoneyLogSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") MoneyLog record, @Param("example") MoneyLogExample example);

    @UpdateProvider(type=MoneyLogSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") MoneyLog record, @Param("example") MoneyLogExample example);

    @UpdateProvider(type=MoneyLogSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(MoneyLog record);

    @Update({
        "update money_log",
        "set uid = #{uid,jdbcType=BIGINT},",
          "type = #{type,jdbcType=VARCHAR},",
          "type_id = #{typeId,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "before_money = #{beforeMoney,jdbcType=DECIMAL},",
          "change_money = #{changeMoney,jdbcType=DECIMAL},",
          "after_money = #{afterMoney,jdbcType=DECIMAL},",
          "locking = #{locking,jdbcType=VARCHAR},",
          "remark = #{remark,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(MoneyLog record);
}